<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="68px">
      <el-form-item label="项目名称" prop="projectName">
        <el-input
          v-model="queryParams.projectName"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目类型" prop="projectType">
        <el-select
          v-model="queryParams.projectType"
          placeholder="请选择项目类型"
          clearable
        >
          <el-option
            v-for="dict in dict.type.project_kind_id"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterangeCreatedDate"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report:applyreport:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="applyreportList" @selection-change="handleSelectionChange">
      <el-table-column prop="id" label="序号" type="index">
        <template slot-scope="scope">
          <span v-if="scope.$index != applyreportList.length-1">{{(queryParams.current - 1) * queryParams.size + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="projectName" width="180"/>
      <el-table-column label="项目类型" align="center" prop="projectType" width="100">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.project_kind_id" :value="scope.row.projectType" />
      </template>
      </el-table-column>
      <el-table-column label="建筑垃圾种类" align="center" prop="rubbishType" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.rubbish_type" :value="scope.row.rubbishType"/>
        </template>
      </el-table-column>
      <el-table-column label="处置面积" align="center" prop="disposalArea"/>
      <el-table-column label="处置重量" align="center" prop="disposalWeight"/>
      <el-table-column label="垃圾预估量" align="center" prop="disposalPlanWeight" width="100"/>
      <el-table-column label="预约时间" align="center" prop="bookingDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bookingDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="车辆类别" align="center" prop="carType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.car_type_id" :value="scope.row.carType"/>
        </template>
      </el-table-column>
      <el-table-column label="预计车次" align="center" prop="carNumber"/>
      <el-table-column label="资源化利用企业" align="center" prop="disposalLandName" width="120"/>
      <el-table-column label="资源化利用企业联系人" align="center" prop="disposalLandPerson" width="150"/>
      <el-table-column label="资源化利用企业联系电话" align="center" prop="disposalLandPhone" width="170"/>
      <el-table-column label="资源化企业意见" align="center" prop="disposalSuggestion" width="150"/>
      <el-table-column label="施工单位" align="center" prop="constructionDept"/>
      <el-table-column label="施工单位联系人" align="center" prop="constructionPerson" width="150"/>
      <el-table-column label="施工单位联系电话" align="center" prop="constructionPhone" width="150"/>
      <el-table-column label="施工单位意见" align="center" prop="constructionSuggestion" width="150"/>
      <el-table-column label="监理单位" align="center" prop="supervisorDept"/>
      <el-table-column label="监理单位联系人" align="center" prop="supervisorPerson" width="150"/>
      <el-table-column label="监理单位联系电话" align="center" prop="supervisorPhone" width="150"/>
      <el-table-column label="监理单位意见" align="center" prop="supervisorSuggestion" width="150"/>
      <el-table-column label="运输单位" align="center" prop="transportCompanyId"/>
      <el-table-column label="运输单位联系人" align="center" prop="transportCompanyPerson" width="150"/>
      <el-table-column label="运输单位联系电话" align="center" prop="transportCompanyPhone" width="150"/>
      <el-table-column label="运输单位意见" align="center" prop="transportCompanySuggestion" width="150"/>
      <el-table-column label="状态" align="center" prop="approvalStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.approval_status" :value="scope.row.approvalStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="审批意见" align="center" prop="approvalDesc"/>
      <el-table-column label="创建时间" align="center" prop="createdDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createdDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listApplyreport} from "@/api/report/applyreport";

export default {
  name: "Applyreport",
  dicts: ['approval_status', 'car_type_id', 'rubbish_type', 'project_kind_id'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 垃圾申报量统计表格数据
      applyreportList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 修改时间时间范围
      daterangeCreatedDate: [],
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
        projectName: null,
        projectType: null,
        createdDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询垃圾申报量统计列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeCreatedDate && '' != this.daterangeCreatedDate) {
        this.queryParams.params["beginCreatedDate"] = this.daterangeCreatedDate[0];
        this.queryParams.params["endCreatedDate"] = this.daterangeCreatedDate[1];
      }
      listApplyreport(this.queryParams).then(response => {
        this.applyreportList = response.records;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        projectId: null,
        rubbishType: null,
        disposalArea: null,
        disposalWeight: null,
        disposalPlanWeight: null,
        bookingDate: null,
        carType: null,
        carNumber: null,
        disposalLandId: null,
        disposalLandPerson: null,
        disposalLandPhone: null,
        disposalSuggestion: null,
        constructionDept: null,
        constructionPerson: null,
        constructionPhone: null,
        constructionSuggestion: null,
        supervisorDept: null,
        supervisorPerson: null,
        supervisorPhone: null,
        supervisorSuggestion: null,
        transportCompanyId: null,
        transportCompanyPerson: null,
        transportCompanyPhone: null,
        transportCompanySuggestion: null,
        projectImages: null,
        approvalStatus: null,
        approvalDesc: null,
        approvalDate: null,
        createdDate: null,
        modifiedDate: null,
        projectName: null,
        projectType: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCreatedDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report/applyreport/export', {
        ...this.queryParams
      }, `applyreport_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
